<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>🎣 钓鱼小程序数据库设计文档</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; padding: 20px; }
        .header { text-align: center; margin-bottom: 30px; background: white; padding: 30px; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
        .header h1 { color: #3498DB; font-size: 28px; margin-bottom: 10px; }
        .header p { color: #666; font-size: 16px; }
        .section { background: white; border-radius: 12px; padding: 25px; margin-bottom: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
        .section h2 { color: #2c3e50; font-size: 20px; margin-bottom: 15px; border-bottom: 2px solid #3498DB; padding-bottom: 8px; }
        .table-container { overflow-x: auto; margin-bottom: 20px; }
        table { width: 100%; border-collapse: collapse; font-size: 14px; }
        th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
        th { background-color: #3498DB; color: white; font-weight: 600; }
        tr:hover { background-color: #f8f9fa; }
        .module-tag { background: #e74c3c; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; margin-bottom: 10px; display: inline-block; }
        .summary { background: #ecf0f1; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
    </style>
</head>
<body>
    <div class="header">
        <h1>🎣 钓鱼小程序数据库设计文档</h1>
        <p>专业的钓鱼服务平台 | 入场券·渔具·会员服务 | 数据库架构设计</p>
    </div>

    <div class="summary">
        <h3>📊 数据库概览</h3>
        <p><strong>总表数：</strong>15张核心业务表</p>
        <p><strong>主要模块：</strong>用户管理、入场券系统、商城订单、社交沸点、会员体系、钓鱼记录</p>
        <p><strong>设计原则：</strong>高内聚低耦合、支持高并发、数据一致性保证</p>
    </div>

    <div class="section">
        <div class="module-tag">用户模块</div>
        <h2>1. 用户表 (users)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>用户ID</td></tr>
                    <tr><td>openid</td><td>VARCHAR(64)</td><td>UNIQUE NOT NULL</td><td>微信openid</td></tr>
                    <tr><td>unionid</td><td>VARCHAR(64)</td><td>UNIQUE</td><td>微信unionid</td></tr>
                    <tr><td>nickname</td><td>VARCHAR(50)</td><td>NOT NULL</td><td>用户昵称</td></tr>
                    <tr><td>avatar</td><td>VARCHAR(255)</td><td></td><td>头像地址</td></tr>
                    <tr><td>phone</td><td>VARCHAR(11)</td><td>UNIQUE</td><td>手机号</td></tr>
                    <tr><td>gender</td><td>TINYINT</td><td>DEFAULT 0</td><td>性别(0未知1男2女)</td></tr>
                    <tr><td>membership_level</td><td>TINYINT</td><td>DEFAULT 0</td><td>会员等级(0普通1银卡2金卡3钻石)</td></tr>
                    <tr><td>membership_expire</td><td>DATETIME</td><td></td><td>会员到期时间</td></tr>
                    <tr><td>balance</td><td>DECIMAL(10,2)</td><td>DEFAULT 0.00</td><td>余额</td></tr>
                    <tr><td>points</td><td>INT</td><td>DEFAULT 0</td><td>积分</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 1</td><td>状态(0禁用1正常)</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                    <tr><td>updated_at</td><td>TIMESTAMP</td><td>ON UPDATE CURRENT_TIMESTAMP</td><td>更新时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>2. 用户地址表 (user_addresses)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>地址ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>name</td><td>VARCHAR(50)</td><td>NOT NULL</td><td>收货人姓名</td></tr>
                    <tr><td>phone</td><td>VARCHAR(11)</td><td>NOT NULL</td><td>收货人电话</td></tr>
                    <tr><td>province</td><td>VARCHAR(20)</td><td>NOT NULL</td><td>省份</td></tr>
                    <tr><td>city</td><td>VARCHAR(20)</td><td>NOT NULL</td><td>城市</td></tr>
                    <tr><td>district</td><td>VARCHAR(20)</td><td>NOT NULL</td><td>区县</td></tr>
                    <tr><td>detail</td><td>VARCHAR(200)</td><td>NOT NULL</td><td>详细地址</td></tr>
                    <tr><td>is_default</td><td>TINYINT</td><td>DEFAULT 0</td><td>是否默认地址</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">入场券模块</div>
        <h2>3. 入场券类型表 (ticket_types)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>券种ID</td></tr>
                    <tr><td>name</td><td>VARCHAR(100)</td><td>NOT NULL</td><td>券种名称</td></tr>
                    <tr><td>description</td><td>TEXT</td><td></td><td>券种描述</td></tr>
                    <tr><td>price</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>价格</td></tr>
                    <tr><td>duration_hours</td><td>INT</td><td>NOT NULL</td><td>有效时长(小时)</td></tr>
                    <tr><td>location</td><td>VARCHAR(200)</td><td>NOT NULL</td><td>钓点位置</td></tr>
                    <tr><td>facilities</td><td>JSON</td><td></td><td>设施配套</td></tr>
                    <tr><td>images</td><td>JSON</td><td></td><td>图片地址</td></tr>
                    <tr><td>stock</td><td>INT</td><td>DEFAULT 0</td><td>库存数量</td></tr>
                    <tr><td>sales_count</td><td>INT</td><td>DEFAULT 0</td><td>销售数量</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 1</td><td>状态(0下架1上架)</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>4. 用户入场券表 (user_tickets)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>券实例ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>ticket_type_id</td><td>BIGINT</td><td>NOT NULL</td><td>券种ID</td></tr>
                    <tr><td>order_id</td><td>BIGINT</td><td>NOT NULL</td><td>订单ID</td></tr>
                    <tr><td>ticket_code</td><td>VARCHAR(32)</td><td>UNIQUE NOT NULL</td><td>券码</td></tr>
                    <tr><td>qr_code</td><td>VARCHAR(255)</td><td></td><td>二维码地址</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 0</td><td>状态(0未使用1已使用2已过期)</td></tr>
                    <tr><td>start_time</td><td>DATETIME</td><td></td><td>开始使用时间</td></tr>
                    <tr><td>end_time</td><td>DATETIME</td><td></td><td>结束时间</td></tr>
                    <tr><td>used_at</td><td>DATETIME</td><td></td><td>使用时间</td></tr>
                    <tr><td>expired_at</td><td>DATETIME</td><td>NOT NULL</td><td>过期时间</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">商城模块</div>
        <h2>5. 商品表 (products)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>商品ID</td></tr>
                    <tr><td>name</td><td>VARCHAR(200)</td><td>NOT NULL</td><td>商品名称</td></tr>
                    <tr><td>description</td><td>TEXT</td><td></td><td>商品描述</td></tr>
                    <tr><td>category_id</td><td>BIGINT</td><td>NOT NULL</td><td>分类ID</td></tr>
                    <tr><td>brand</td><td>VARCHAR(100)</td><td></td><td>品牌</td></tr>
                    <tr><td>price</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>售价</td></tr>
                    <tr><td>original_price</td><td>DECIMAL(10,2)</td><td></td><td>原价</td></tr>
                    <tr><td>cost_price</td><td>DECIMAL(10,2)</td><td></td><td>成本价</td></tr>
                    <tr><td>stock</td><td>INT</td><td>DEFAULT 0</td><td>库存</td></tr>
                    <tr><td>sales_count</td><td>INT</td><td>DEFAULT 0</td><td>销量</td></tr>
                    <tr><td>images</td><td>JSON</td><td></td><td>商品图片</td></tr>
                    <tr><td>specs</td><td>JSON</td><td></td><td>规格信息</td></tr>
                    <tr><td>weight</td><td>DECIMAL(8,2)</td><td></td><td>重量(kg)</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 1</td><td>状态(0下架1上架)</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>6. 购物车表 (shopping_cart)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>购物车ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>product_id</td><td>BIGINT</td><td>NOT NULL</td><td>商品ID</td></tr>
                    <tr><td>quantity</td><td>INT</td><td>NOT NULL</td><td>数量</td></tr>
                    <tr><td>selected</td><td>TINYINT</td><td>DEFAULT 1</td><td>是否选中</td></tr>
                    <tr><td>spec_info</td><td>JSON</td><td></td><td>规格信息</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">订单模块</div>
        <h2>7. 订单表 (orders)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>订单ID</td></tr>
                    <tr><td>order_no</td><td>VARCHAR(32)</td><td>UNIQUE NOT NULL</td><td>订单号</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>type</td><td>TINYINT</td><td>NOT NULL</td><td>订单类型(1入场券2商品3会员)</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 0</td><td>状态(0待支付1已支付2已发货3已完成4已取消5已退款)</td></tr>
                    <tr><td>total_amount</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>订单总金额</td></tr>
                    <tr><td>discount_amount</td><td>DECIMAL(10,2)</td><td>DEFAULT 0.00</td><td>优惠金额</td></tr>
                    <tr><td>shipping_fee</td><td>DECIMAL(10,2)</td><td>DEFAULT 0.00</td><td>运费</td></tr>
                    <tr><td>pay_amount</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>实付金额</td></tr>
                    <tr><td>shipping_address</td><td>JSON</td><td></td><td>收货地址</td></tr>
                    <tr><td>remark</td><td>VARCHAR(500)</td><td></td><td>订单备注</td></tr>
                    <tr><td>paid_at</td><td>DATETIME</td><td></td><td>支付时间</td></tr>
                    <tr><td>shipped_at</td><td>DATETIME</td><td></td><td>发货时间</td></tr>
                    <tr><td>completed_at</td><td>DATETIME</td><td></td><td>完成时间</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>8. 订单明细表 (order_items)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>明细ID</td></tr>
                    <tr><td>order_id</td><td>BIGINT</td><td>NOT NULL</td><td>订单ID</td></tr>
                    <tr><td>product_id</td><td>BIGINT</td><td></td><td>商品ID</td></tr>
                    <tr><td>ticket_type_id</td><td>BIGINT</td><td></td><td>入场券类型ID</td></tr>
                    <tr><td>product_name</td><td>VARCHAR(200)</td><td>NOT NULL</td><td>商品名称</td></tr>
                    <tr><td>product_image</td><td>VARCHAR(255)</td><td></td><td>商品图片</td></tr>
                    <tr><td>spec_info</td><td>JSON</td><td></td><td>规格信息</td></tr>
                    <tr><td>price</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>单价</td></tr>
                    <tr><td>quantity</td><td>INT</td><td>NOT NULL</td><td>数量</td></tr>
                    <tr><td>total_amount</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>小计金额</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">社交模块</div>
        <h2>9. 沸点动态表 (moments)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>动态ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>发布用户ID</td></tr>
                    <tr><td>content</td><td>TEXT</td><td>NOT NULL</td><td>动态内容</td></tr>
                    <tr><td>images</td><td>JSON</td><td></td><td>图片地址</td></tr>
                    <tr><td>video</td><td>VARCHAR(255)</td><td></td><td>视频地址</td></tr>
                    <tr><td>location</td><td>VARCHAR(200)</td><td></td><td>位置信息</td></tr>
                    <tr><td>topic_id</td><td>BIGINT</td><td></td><td>话题ID</td></tr>
                    <tr><td>like_count</td><td>INT</td><td>DEFAULT 0</td><td>点赞数</td></tr>
                    <tr><td>comment_count</td><td>INT</td><td>DEFAULT 0</td><td>评论数</td></tr>
                    <tr><td>share_count</td><td>INT</td><td>DEFAULT 0</td><td>分享数</td></tr>
                    <tr><td>is_top</td><td>TINYINT</td><td>DEFAULT 0</td><td>是否置顶</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 1</td><td>状态(0隐藏1正常2审核中)</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>10. 动态点赞表 (moment_likes)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>点赞ID</td></tr>
                    <tr><td>moment_id</td><td>BIGINT</td><td>NOT NULL</td><td>动态ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>点赞时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>11. 动态评论表 (moment_comments)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>评论ID</td></tr>
                    <tr><td>moment_id</td><td>BIGINT</td><td>NOT NULL</td><td>动态ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>评论用户ID</td></tr>
                    <tr><td>parent_id</td><td>BIGINT</td><td></td><td>父评论ID</td></tr>
                    <tr><td>content</td><td>VARCHAR(500)</td><td>NOT NULL</td><td>评论内容</td></tr>
                    <tr><td>like_count</td><td>INT</td><td>DEFAULT 0</td><td>点赞数</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>评论时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">钓鱼记录模块</div>
        <h2>12. 钓鱼记录表 (fishing_records)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>记录ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>ticket_id</td><td>BIGINT</td><td>NOT NULL</td><td>入场券ID</td></tr>
                    <tr><td>start_time</td><td>DATETIME</td><td>NOT NULL</td><td>开始时间</td></tr>
                    <tr><td>end_time</td><td>DATETIME</td><td></td><td>结束时间</td></tr>
                    <tr><td>duration_minutes</td><td>INT</td><td></td><td>钓鱼时长(分钟)</td></tr>
                    <tr><td>fish_count</td><td>INT</td><td>DEFAULT 0</td><td>钓鱼数量</td></tr>
                    <tr><td>total_weight</td><td>DECIMAL(8,2)</td><td>DEFAULT 0.00</td><td>总重量(kg)</td></tr>
                    <tr><td>fish_types</td><td>JSON</td><td></td><td>鱼类信息</td></tr>
                    <tr><td>photos</td><td>JSON</td><td></td><td>钓鱼照片</td></tr>
                    <tr><td>weather</td><td>VARCHAR(50)</td><td></td><td>天气情况</td></tr>
                    <tr><td>temperature</td><td>VARCHAR(20)</td><td></td><td>温度</td></tr>
                    <tr><td>notes</td><td>TEXT</td><td></td><td>钓鱼笔记</td></tr>
                    <tr><td>points_earned</td><td>INT</td><td>DEFAULT 0</td><td>获得积分</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">会员模块</div>
        <h2>13. 会员购买记录表 (membership_orders)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>记录ID</td></tr>
                    <tr><td>user_id</td><td>BIGINT</td><td>NOT NULL</td><td>用户ID</td></tr>
                    <tr><td>order_id</td><td>BIGINT</td><td>NOT NULL</td><td>订单ID</td></tr>
                    <tr><td>membership_type</td><td>TINYINT</td><td>NOT NULL</td><td>会员类型(1银卡2金卡3钻石)</td></tr>
                    <tr><td>duration_months</td><td>INT</td><td>NOT NULL</td><td>有效期(月)</td></tr>
                    <tr><td>original_price</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>原价</td></tr>
                    <tr><td>discount_price</td><td>DECIMAL(10,2)</td><td>NOT NULL</td><td>优惠价</td></tr>
                    <tr><td>start_date</td><td>DATE</td><td>NOT NULL</td><td>开始日期</td></tr>
                    <tr><td>end_date</td><td>DATE</td><td>NOT NULL</td><td>结束日期</td></tr>
                    <tr><td>benefits</td><td>JSON</td><td></td><td>会员权益</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 1</td><td>状态(0失效1有效)</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <div class="module-tag">系统模块</div>
        <h2>14. 商品分类表 (product_categories)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>分类ID</td></tr>
                    <tr><td>name</td><td>VARCHAR(50)</td><td>NOT NULL</td><td>分类名称</td></tr>
                    <tr><td>parent_id</td><td>BIGINT</td><td>DEFAULT 0</td><td>父分类ID</td></tr>
                    <tr><td>level</td><td>TINYINT</td><td>DEFAULT 1</td><td>分类层级</td></tr>
                    <tr><td>sort_order</td><td>INT</td><td>DEFAULT 0</td><td>排序</td></tr>
                    <tr><td>icon</td><td>VARCHAR(255)</td><td></td><td>分类图标</td></tr>
                    <tr><td>status</td><td>TINYINT</td><td>DEFAULT 1</td><td>状态(0禁用1启用)</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>15. 系统配置表 (system_configs)</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr><th>字段名</th><th>类型</th><th>约束</th><th>说明</th></tr>
                </thead>
                <tbody>
                    <tr><td>id</td><td>BIGINT</td><td>PRIMARY KEY AUTO_INCREMENT</td><td>配置ID</td></tr>
                    <tr><td>config_key</td><td>VARCHAR(100)</td><td>UNIQUE NOT NULL</td><td>配置键</td></tr>
                    <tr><td>config_value</td><td>TEXT</td><td></td><td>配置值</td></tr>
                    <tr><td>config_desc</td><td>VARCHAR(200)</td><td></td><td>配置说明</td></tr>
                    <tr><td>config_type</td><td>VARCHAR(20)</td><td>DEFAULT 'string'</td><td>配置类型</td></tr>
                    <tr><td>created_at</td><td>TIMESTAMP</td><td>DEFAULT CURRENT_TIMESTAMP</td><td>创建时间</td></tr>
                    <tr><td>updated_at</td><td>TIMESTAMP</td><td>ON UPDATE CURRENT_TIMESTAMP</td><td>更新时间</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="section">
        <h2>📋 核心索引建议</h2>
        <div style="background: #f8f9fa; padding: 15px; border-radius: 8px;">
            <h4>高频查询索引：</h4>
            <ul style="margin: 10px 0 0 20px;">
                <li><code>CREATE INDEX idx_users_openid ON users(openid);</code></li>
                <li><code>CREATE INDEX idx_orders_user_status ON orders(user_id, status);</code></li>
                <li><code>CREATE INDEX idx_user_tickets_user_status ON user_tickets(user_id, status);</code></li>
                <li><code>CREATE INDEX idx_moments_user_created ON moments(user_id, created_at DESC);</code></li>
                <li><code>CREATE INDEX idx_fishing_records_user_start ON fishing_records(user_id, start_time DESC);</code></li>
                <li><code>CREATE INDEX idx_products_category_status ON products(category_id, status);</code></li>
            </ul>
        </div>
    </div>

    <div class="section">
        <h2>🔗 核心外键关系</h2>
        <div style="background: #f8f9fa; padding: 15px; border-radius: 8px;">
            <h4>主要表关联：</h4>
            <ul style="margin: 10px 0 0 20px;">
                <li><strong>用户 ← 地址：</strong> user_addresses.user_id → users.id</li>
                <li><strong>用户 ← 订单：</strong> orders.user_id → users.id</li>
                <li><strong>订单 ← 明细：</strong> order_items.order_id → orders.id</li>
                <li><strong>用户 ← 入场券：</strong> user_tickets.user_id → users.id</li>
                <li><strong>券种 ← 用户券：</strong> user_tickets.ticket_type_id → ticket_types.id</li>
                <li><strong>用户 ← 动态：</strong> moments.user_id → users.id</li>
                <li><strong>动态 ← 点赞：</strong> moment_likes.moment_id → moments.id</li>
                <li><strong>用户 ← 钓鱼记录：</strong> fishing_records.user_id → users.id</li>
            </ul>
        </div>
    </div>
</body>
</html> 